/*
 * Filename MQTTInfoController.java 2022年04月19日
 * Copyright © Ehome Co.Ltd. All Rgiths Reserved.
 * @author wuyingchao
 */
package com.ehome.poct.base.controller.sys;

import com.ehome.poct.base.api.dto.sys.MqttInfoDTO;
import com.ehome.poct.base.api.dto.sys.MqttMsg;
import com.ehome.poct.base.api.virtual.sys.MqttInfoService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wyc
 * @since 2022/04/19 14:53
 **/
@Api(tags="系统字典")
@ApiSupport(author = "wyc")
@RequestMapping("/sys/mqtt")
@RestController
@AllArgsConstructor
public class MqttInfoController {
    private MqttInfoService mqttInfoService;

    @ApiOperation("获取消息服务器信息")
    @ApiOperationSupport(author = "wyc")
    @RequestMapping("/one")
    public MqttInfoDTO getInfo() {
        return mqttInfoService.get();
    }
    @ApiOperation("发送mqtt请求")
    @ApiOperationSupport(author = "muqiu")
    @PostMapping("/sendToMqtt")
    public void sendToMqtt(@RequestBody MqttMsg mqttMsg){
        mqttInfoService.sendToMqtt(mqttMsg.getData(),mqttMsg.getTopic());
    }
}